widget: Set .default class when widget is default
authorBenjamin Otte <otte@redhat.com>
Wed, 11 Apr 2012 12:56:15 +0000 (14:56 +0200)
committerBenjamin Otte <otte@redhat.com>
Tue, 17 Apr 2012 06:59:22 +0000 (08:59 +0200)
Don't just conditionally set it on buttons.

gtk/gtkbutton.c
gtk/gtkwidget.c

index 6a6d7c3147b92164e2a9ee732c25234ff56d49e3..1ecd6d1468867ce322b8d7510269c31cd28ae584 100644 (file)
@@ -1720,8 +1720,6 @@ _gtk_button_paint (GtkButton          *button,
       y += default_border.top;
       width -= default_border.left + default_border.right;
       height -= default_border.top + default_border.bottom;
-
-      gtk_style_context_add_class (context, GTK_STYLE_CLASS_DEFAULT);
     }
   else if (gtk_widget_get_can_default (widget))
     {
index 5b2aa3f7195e93576335e5f38bf49f1ef844b1c7..ff3c55265047fdbd03da4f0baa93c23506a9ca13 100644 (file)
@@ -6994,7 +6994,16 @@ void
 _gtk_widget_set_has_default (GtkWidget *widget,
                              gboolean   has_default)
 {
+  GtkStyleContext *context;
+
   widget->priv->has_default = has_default;
+
+  context = gtk_widget_get_style_context (widget);
+
+  if (has_default)
+    gtk_style_context_add_class (context, GTK_STYLE_CLASS_DEFAULT);
+  else
+    gtk_style_context_remove_class (context, GTK_STYLE_CLASS_DEFAULT);
 }
 
 /**